using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// ILPData Test Class
  /// </summary>
  [TestClass]
  public class TestILPData
  {
    #region Class Variables
    private CdoPrms<DOILPData>		m_ILPData;
    private CdoPrmsList<DOILPData>	m_AllILPData;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestILPData()
    {
      // Create the data objects
      this.m_ILPData	= new CdoPrms<DOILPData>();
      this.m_AllILPData	= new CdoPrmsList<DOILPData>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all ILPData data objects
    /// </summary>
    [TestMethod]
    public void ILPDataRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllILPData.DataObject = new DOILPData();
      this.m_AllILPData.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllILPData.PerformAction())
      {
        // Assert the errors
        if (this.m_AllILPData.Errors.Count > 0) { Assert.Fail(this.m_AllILPData.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new ILPData
    /// </summary>
    [TestMethod]
    public void ILPDataCreate()
    {
      // Set up the data object for creation
      this.m_ILPData.DataObject.AccNo = "Test AccNo";
      this.m_ILPData.DataObject.BondAmt = 12.3M;
      this.m_ILPData.DataObject.OutBal = 12.3M;
      this.m_ILPData.DataObject.AmtPastDue = 12.3M;
      this.m_ILPData.DataObject.ValAmt = 12.3M;
      this.m_ILPData.DataObject.PrePaid = 12.3M;
      this.m_ILPData.DataObject.Monthly = 12.3M;
      this.m_ILPData.DataObject.BondRegDate = DateTime.Now;
      this.m_ILPData.DataObject.ValDate = DateTime.Now;
      this.m_ILPData.DataObject.Status = 'b';
      this.m_ILPData.DataObject.SubStatus = 'b';
      this.m_ILPData.DataObject.BranchCode = 'b';
      this.m_ILPData.DataObject.custID = "Test custID";
      this.m_ILPData.DataObject.custName1 = "Test custName1";
      this.m_ILPData.DataObject.custName2 = "Test custName2";
      this.m_ILPData.DataObject.custPersTel = "Test custPersTel";
      this.m_ILPData.DataObject.custBussTel = "Test custBussTel";
      this.m_ILPData.DataObject.custContTel = "Test custContTel";
      this.m_ILPData.DataObject.AccountDate = DateTime.Now;
      this.m_ILPData.DataObject.Suburb = "Test Suburb";
      this.m_ILPData.DataObject.Stand = "Test Stand";
      this.m_ILPData.DataObject.Complex = "Test Complex";
      this.m_ILPData.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_ILPData.PerformAction())
      {
        // Assert the errors
        if (this.m_ILPData.Errors.Count > 0) { Assert.Fail(this.m_ILPData.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific ILPData
    /// </summary>
    [TestMethod]
    public void ILPDataRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_ILPData.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_ILPData.DataObject.Id = 10;
      }

      // Set up the data object action for retrieval
      this.m_ILPData.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_ILPData.PerformAction())
      {
        // Assert the errors
        if (this.m_ILPData.Errors.Count > 0) { Assert.Fail(this.m_ILPData.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
